package com.applet.code.util;

import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;

@Data
@FieldDefaults(level=AccessLevel.PRIVATE)
public class HttpResult {

	public final static HttpResult OK = new HttpResult(200, "操作成功");
	
	public final static HttpResult PARAM_ERROR = new HttpResult(405, "参数列表校验未通过，请求被中断");

	public final static HttpResult VALIDITY_ERROR = new HttpResult(406, "参数有效性校验未通过，请求被中断");

	public final static HttpResult NO_AUTH = new HttpResult(403, "操作失败，权限校验未通过，请求被拒绝");

	public final static HttpResult SYSTEM_ERROR = new HttpResult(503, "系统繁忙,请稍后再试");

	public final static HttpResult FALLBACK = new HttpResult(500, "服务器发生异常，请稍后重试");
	
	public final static HttpResult METHOD_NOT_SUPPORTED = new HttpResult(500, "HTTP请求方式错误");
	
	Integer code;
	
	String msg;
	
	Object data;

	public HttpResult() {
		super();
		this.code = 200;
	}

	public HttpResult(Object data) {
		super();
		this.code = 200;
		this.data = data;
	}

	public HttpResult(Integer code, String msg) {
		super();
		this.code = code;
		this.msg = msg;
	}

	public HttpResult(Integer code, Object data) {
		super();
		this.code = code;
		this.data = data;
	}

	public HttpResult(Integer code, String msg, Object data) {
		super();
		this.code = code;
		this.msg = msg;
		this.data = data;
	}
	

	public static HttpResult fail(String msg) {
		return new HttpResult(505, msg);
	}
	
}
